import request from '@/plugin/axios'
import util from '@/libs/util.js'
const getProvinceList =   function getProvinceList(level,parentName) {
    var data = {};
    data.parentName = parentName;
    data.level = level;
    data.UserId = util.cookies.get('uuid');
    return request({
        url: '/Zone/Child',
        method: 'post',
        data
    })
};
const  getProjectTable = (data)=>request({
    url: '/Project/List',
    method: 'post',
    data:data
});
// const  getWeek = (data)=>request({
//     url: '/Project/weekList',
//     method: 'post',
//     data:data
// });
//选择周次
// const getWeek =   function getWeek(year,week) {
//     var data = {};
//     data.year = year;
//     data.week = week;
//     data.UserId = util.cookies.get('uuid');
//     return request({
//         url: '/Project/weekList',
//         method: 'post',
//         data
//     })
// };
const  getWeekTable = (data)=>request({
    url: '/Project/weekList',
    method: 'post',
    data:data
});
export function getSaveProject (data) {


    return request({
        url: '/Project/Add',
        method: 'post',
        data
    })
}
//提交管理设备数据
export function getManagementData (data) {
    data.UserId = util.cookies.get('uuid');
    return request({
        url: '/Collector/Add',
        method: 'post',
        data
})
}
export function getDeviceTable(data) {
    data.UserId = util.cookies.get('uuid');
    return request({
        url: '/Collector/List',
        method: 'post',
        data
    })
}

export function getProjectUsers(projectId){
    return request({
        url: '/Project/UserList',
        method: 'post',
        data:{ProjectId:projectId}
    })
}

export function getChildUsers(parentId){
    return request({
        url: '/User/Child',
        method: 'post',
        data:{parentId:-1}
    })
}

export function saveProjectUser(projectId,userIds,roles){
    return request({
        url: '/Project/AddUsers',
        method: 'post',
        data:{
            ProjectId:projectId,
            UserIds:userIds,
            Roles:roles
        }
    })
}

//获取业主信息
// export function getUserId(data) {
//     data.UserId = util.cookies.get('uuid');
//     return request({
//         url: '/User/Child',
//         method: 'post',
//         data
// })
// }
// const  getUserId = () =>request({
//     // api/v1/Collector/modeType
//     url: '/User/Child',
//     method: 'post',
//     data:{
//         UserId:util.cookies.get('uuid')
//     }
// });
const getUserId =   function getUserId(UserId) {
    var data = {};
    data.UserId = UserId;
    return request({
        url: '/Zone/Child',
        method: 'post',
        data
    })
};
//表格删除
const deleteProject =   function deleteProject(data) {

    data.UserId = util.cookies.get('uuid');
    return request({
        url: '/Project/Delete',
        method: 'post',
        data
    })
};
const deleteCollector =   function deleteCollector(data) {

    data.UserId = util.cookies.get('uuid');
    return request({
        url: '/Collector/Delete',
        method: 'post',
        data
    })
};

export {
    getProvinceList,
    getProjectTable,
    //getWeek,
    getWeekTable,
    getUserId,
    deleteProject,
    deleteCollector
}

